package com.lxf.cloudotherserve.controller;

import com.alibaba.fastjson.JSONObject;
import com.lxf.cloudotherserve.annotate.OtherRateLimit;
import com.lxf.cloudotherserve.service.UserCLRService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author 罗兴发
 * @data 2025/6/30 14:35
 * @description：用户点赞/收藏/转发-控制层
 */
@RestController
@CrossOrigin  //跨域
@RequestMapping("/v1")
public class UserCLRController {
    @Resource
    UserCLRService userCLRService;

    /**
     * 添加点赞/收藏/转发记录
     * @param json
     * @param request
     * @return
     */
    @OtherRateLimit(value = 2,timeout = 5)
    @PostMapping("/addUserCLR")
    public String addUserCLR(@RequestBody JSONObject json, HttpServletRequest request){
        return userCLRService.addUserCLR(json,request);
    }

    /**
     * 根据用户ID、对象ID、对象类型以及相应标识获取是否点赞/收藏
     * @param json
     * @return
     */
    @OtherRateLimit(value = 2,timeout = 5)
    @PostMapping("/getUserCLRById")
    public String getUserCLRById(@RequestBody JSONObject json){
        return userCLRService.getUserCLRById(json);
    }


    /**
     * 根据用户ID、对象ID、对象类型以及相应标识获取是否点赞/收藏
     * @return
     */
    @OtherRateLimit(value = 2,timeout = 5)
    @GetMapping("/delESUserCLR")
    public String delESUserCLR(){
        return userCLRService.delESUserCLR();
    }

}
